<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css" href="edit68k.css">
<title>Quick Start</title>
</head>

<body class="text">

<p class="heading">Getting Started<hr noshade></p>
<p></p>
<p>The following is a quick introduction to 68000 assembly language 
programming with EASy68K. </p>
<p>An assembly language program consists of:<br>
&nbsp;&nbsp;&nbsp; <b>labels</b> - User created names that mark locations in a 
program.<br>
&nbsp;&nbsp;&nbsp; <b>opcode</b> - Specific instructions the microprocessor can 
perform.<br>
&nbsp;&nbsp;&nbsp; <b>operands</b> - Additional data required by some 
instructions.<br>
&nbsp;&nbsp;&nbsp; <b>directives</b> - Commands to the assembler.<br>
&nbsp;&nbsp;&nbsp; <b>macros</b> - A user created collection of source code that 
may be easily reused when writing a program.<br>
&nbsp;&nbsp;&nbsp; <b>comments</b> - User created strings of text used to 
document a program.</p>
<p>Each line of an assembly language program contains a combination 
of the following four fields.&nbsp; </p>
<p><b>Label Field</b><br>
A label is used to identify a location in a program or a memory location by 
name. Instructions or directives that require a location may use a label to 
indicate the location. A label normally begins in the first column of the line. 
It must be terminated with a space, tab or a colon. If a colon is used it does 
not become part of the label. If a label does not start in the first column it 
must be terminated with a colon.&nbsp; Only the first 32 characters of the label are significant. 
Two types of labels are available: Global and Local. A global label may be 
referenced from anywhere in the program. As such, global labels must be a unique 
name. Global labels should start with a letter and be followed by letters, 
numbers or underscores. Local labels may be reused in a program. Local labels 
must start with a dot '.' and be followed by letters, numbers or underscores. 
Global labels define the boundaries of a local label. When a local label is 
defined it may only be referenced from code above or below the local label until 
the next global label is encountered. The assembler creates a unique name for 
local labels by appending the local label name to the preceding global label and 
replacing the dot with a colon ':'. Only the first 32 characters of the 
resulting name are significant.</p>
<p><b>Operation Field</b><br>
The operation field follows the label field. If must be separated from the 
label by at least one space or tab. If no label is present on the line there must be at 
least one space or tab before the operation. Operations may be 68000 opcodes, assembler 
directives or macro calls.</p>
<p><b>Operand Field</b><br>
Operands contain extra information required by the item in the operation 
field. Not all operations required extra information so an operand may not be 
required. The operand field must be separated from the operation field by at 
least one space or tab.</p>
<p><b>Comment Field</b><br>
The last item on the source line is a comment area. User entered text is 
placed here to document the program. The assembler ignores everything in the 
comment field. The comment field must be separated from the previous field by at 
least one space or tab.</p>
<p>For example:<i><br>
<u>label&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opcode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; operand&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; comment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</u></i><u><br>
</u><font face="Courier New" size="3" color="#800080">.Loop</font><font face="Courier New" size="3">&nbsp;&nbsp;&nbsp;&nbsp; ADD&nbsp;&nbsp;&nbsp; D0,D1&nbsp;&nbsp;&nbsp; <font color="#0000FF">&nbsp;&nbsp;&nbsp; Add two numbers<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font>BMI&nbsp;&nbsp;&nbsp; 
.Loop<font color="#0000FF">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Loop 
while negative<br>
<br>
</font></font>Assembly language programming requires direct interaction with the 
microprocessor. The 68000 microprocessor contains eight data registers D0 
through D7. Data registers are general purpose. They may be thought of as 8 bit, 
16 bit or 32 bit 
integer variables. There are eight address registers A0 through A7. Address 
registers are 32 bits long. They are most commonly used to reference variables. 
The status register (SR) contains status flags that indicate the results of 
comparisons. The EASy68K simulator displays the registers of the 68000 as:</p>
<p>
<img border="0" src="Images/Registers.GIF" width="735" height="139"></p>
<p>&nbsp;</p>
<p>The following program will display the text &quot;Hello World&quot; and 
the number contained in D1. This is the program as it appears in the editor.</p>
<p>
<img border="0" src="Images/OutputDemo.GIF" width="625" height="432"></p>
<p><b>What it's all about:</b></p>
<p>&nbsp;&nbsp;&nbsp; 
<font color="#008000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORG</font>&nbsp;&nbsp;&nbsp; $1000&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000FF"> 
the program will load into address $1000</font><br>
ORG $1000 defines 
where the program will be located in memory. Dollar sign '$' indicates a 
hexadecimal number.&nbsp; The remaining blue text on the line is comment.</p>
<p><font color="#0000FF">* Display HELLO message</font><br>
Lines that begins with an asterisk '*' are comments.</p>
<p><font color="#800080">START</font>&nbsp;&nbsp;&nbsp; 
MOVE&nbsp;&nbsp;&nbsp; #14,D0&nbsp;&nbsp;&nbsp; <font color="#0000FF">&nbsp;&nbsp;&nbsp; put text 
display task number in D0</font><br>
START is a label. The START label is referenced by the END directive in the last 
line in the program. It is used to indicate where the program should begin 
execution.
MOVE is the opcode, #14,D0 is the operand. The MOVE instruction moves the number 
14 into data register D0. The '#' sign in front of the 14 indicates an immediate 
or literal value. Without the '#' the instruction would get the contents of address 14 and put it in register D0.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
LEA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HELLO,A1&nbsp;&nbsp;&nbsp;
<font color="#0000FF">load address of string to display into A1</font><br>
LEA loads the address of HELLO into address register A1. A1 now points to the 
string at the address defined by the HELLO label.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
TRAP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#0000FF">activates input/ouput task</font><br>
TRAP #15 is used to run Simulator I/O routines (tasks) that are built into the 
Sim68K simulator. The task number to run is in register D0. In this case the 
task number is 14 which tells Sim68K to display the null terminated string pointed to by 
register A1. See <a href="simio.htm">Simulator I/O </a>in this help for a 
complete list of TRAP #15 tasks.</p>
<p>The next three lines of code display the number 12345678.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MOVE.L&nbsp;&nbsp;&nbsp; 
#12345678,D1&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000FF">put a number in D1 so 
we can display it<br>
</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MOVE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
#3,D0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000FF">task 
number 3 in D0</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TRAP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
#15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#0000FF">display number in D1</font></p>
<p>The following two lines of code are used to stop a program. They 
tell the simulator to halt.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MOVE.B&nbsp;&nbsp;&nbsp; 
#9,D0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TRAP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
#15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#0000FF">Halt Simulator</font></p>
<p><font color="#800080">HELLO</font>&nbsp;&nbsp;&nbsp; <font color="#008000">DC.B</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<font color="#008080">'Hello World'</font>,$D,$A,0&nbsp;&nbsp;&nbsp;
<font color="#0000FF">null terminated string with newline</font><br>
This line defines a text string named HELLO. DC.B defines constant bytes. The 
text string is enclosed in single quotes. $D is carriage return, $A is line feed 
and 0 is the null terminator.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#008000">END</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; START<br>
END indicates the end of the assembly program. START is the name of the label 
where the simulator will begin running the program.</p>
<p>To run the program click the Assemble Source button on the 
toolbar <img border="0" src="Images/ToolAssemble.GIF" width="23" height="23"></p>
<p>
<img border="0" src="Images/AssemblerStatus.GIF" width="313" height="127"></p>
<p>
If errors are detected error messages will be displayed at the bottom of the 
editor window. Double click on an error message to highlight the line of code in 
the source. Error messages are also added to the listing file (.L68 extension) 
if the option is selected to create it (default). Source files have a default 
extension of (.X68). Files that may be executed by the simulator have an 
extension of (.S68).</p>
<p>If no errors occur, click the Execute button and the program is loaded into the 
68000 simulator Sim68K.</p>
<p>
<img border="0" src="Images/OutputDemoSimulator.GIF" width="744" height="503"></p>
<p>To run the program click the Run button on the toolbar.
<img border="0" src="Images/ToolAssemble.GIF" width="23" height="23"> The output 
of the program is displayed.</p>
<p>
<img border="0" src="Images/OutputDemoRun.GIF" width="134" height="86"></p>
<p>See the EASy68K EXAMPLES folder for more example programs. More examples are also available at
<a href="http://www.easy68k.com">www.easy68k.com</a></p>

